<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""DTD/xhtml1-strict.dtd">
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@taglib uri="/WEB-INF/el.tld" prefix="el"%>
<%@taglib uri="/WEB-INF/fn.tld" prefix="fn"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title></title>
		<c:import url="/includes/css_inc.jsp"/>
		<c:import url="/includes/js_inc.jsp"/>
		<script>
		$(function(){
			$("#addBtn").button({
	            icons: {
	                primary: "ui-icon-plusthick"
	            }
			}).click(function(){
				$("#job").val("add");
				$("#searchForm").submit();
			});
			$("#btnSearch").button({
	            icons: {
	                primary: "ui-icon-search"
	            }
			});
			$("[name=view]").button({
	            icons: {
	                primary: "ui-icon-search"
	            },
	            text : false
			});
			$("[name=edit]").button({
	            icons: {
	                primary: "ui-icon-pencil"
	            },
	            text : false
			});
		});
		function editCategoryData(categoryId){
			window.location='${pageContext.request.contextPath}/acc6?app=ACC60106&job=viewUpdate&categoryId='+categoryId;
		}
		</script>
	</head>
	<body>
		<c:set var="auth" value="${el:getMapValue(menuAuth, 'ACC60106')}"/>
		<c:import url="/apps/msg.jsp"/>
		<form class="acc67-form" name="searchForm" id="searchForm" action="${pageContext.request.contextPath}/acc6" method="post">
		<input type="hidden" name="app" id="app" value="ACC60106"/>
		<input type="hidden" name="job" id="job" value="search"/>
		<table width="100%" class="ui-widget ui-widget-content" border="0">
			<tr>
				<th align="left" class="acc67-header ui-widget-header" colspan="2"><b>${screenCode.ACC60106}</b></th>
			</tr>
			<tr>
				<td align="right" colspan="2">
					<c:if test="${fn:contains(auth, 'I')}">
						<button type="button" name="addBtn" id="addBtn" class="acc67-button">เพิ่มข้อมูล</button>
					</c:if>
				</td>
			</tr>
			<tr>
				<td width="20%" class="bold">ชื่อหมวดการจ่าย : </td>
				<td><input type="text" name="categoryName" id="categoryName"></td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<c:if test="${fn:contains(auth, 'S')}">
						<button type="submit" name="btnSearch" id="btnSearch" class="acc67-button">ค้นหาข้อมูล</button>
					</c:if>
				</td>
			</tr>
		</table>
		<br/>
		<c:if test="${!empty pageBean.pageData}">
		<fieldset>
			<legend> ผลการค้นหาข้อมูล </legend>
				<table width="100%" class="acc67-grid ui-widget ui-widget-content" border="0">
					<tr>
						<th align="center" class="ui-state-default" width="15%" onclick="pageControl('S', 'CATEGORY_ID');"><span id="CATEGORY_ID" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>รหัสหมวดการจ่าย</th>
						<th align="center" class="ui-state-default" onclick="pageControl('S', 'CATEGORY_NAME');"><span id="CATEGORY_NAME" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>ชื่อหมวดการจ่าย</th>
						<th align="center" class="ui-state-default">คำอธิบายหมวดการจ่าย</th>
						<th align="center" class="ui-state-default" width="8%" onclick="pageControl('S', 'ACTIVE');"><span id="ACTIVE" class="ui-icon ui-icon-triangle-2-n-s" style="float: right;"></span>สถานะ</th>					
						<c:if test="${userInfo.areaLevel!='2' &&  fn:contains(auth, 'U')}">
							<th align="center" class="ui-state-default" width="5%">แก้ไข</th>
						</c:if>
						<c:if test="${userInfo.areaLevel=='2'  && fn:contains(auth, 'S') }">
							<th align="center" class="ui-state-default" width="5%">เรียกดู</th>
						</c:if>
						</tr>
					<c:forEach var="data" items="${pageBean.pageData}" varStatus="x">
						<tr class="grid-tr-${x.count % 2}">
							<td align="center">${data.categoryId}</td>
							<td align="left">${data.categoryName}</td>
							<td align="left">${data.categoryDesc}</td>
							<td align="center">
								<c:if test="${data.active == 'Y'}">
									ใช้งาน
								</c:if>
								<c:if test="${data.active == 'N'}">
									ไม่ใช้งาน
								</c:if>
							</td>
							<td align="center">
								<c:if test="${userInfo.areaLevel!='2' && fn:contains(auth, 'U')}">
									<button type="button" name="edit" id="edit" class="acc67-button" onclick="editCategoryData('${data.categoryId}');"/>
								</c:if>
								<c:if test="${userInfo.areaLevel=='2' && fn:contains(auth, 'S')}">
									<button type="button" name="view" id="view" class="acc67-button" onclick="editCategoryData('${data.categoryId}');"/>
								</c:if>
							</td>
						</tr>
					</c:forEach>
					<input type="hidden" name="formPage" id="formPage" value="searchForm"/>
					<c:import url="/apps/page.jsp"/>
				</table>
		</fieldset>
		</c:if>
		</form>
	</body>
</html>